﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Chromos.ActionEngine;
using Chromos.AIEngine;

namespace Chromos.Actors
{
	class RedBoss : Enemy
	{
		const int moveSpeed = 80;

        public RedBoss(Game1 game, Vector2 position, Vector2 velocity, ContentManager content, bool isStatic, string aggressiveness)
			: base(game, position, velocity, content, isStatic,  aggressiveness)
		{
			this.applyGravity = true;
		}

        protected override void initAIEngine()
		{
			aiEngine = new BossAIEngine(this, "normal", 300, "red");
		}

		protected override void initActorFields()
		{
			base.initActorFields();
			this.health = 1000;
		}

        public override Projectile createProjectiles(int i)
        {
            switch (i)
            {
                case 0:
                    return leftFireP();
                case 1:
                    return rightFireP();
                default:
                    return null;
            }
        }

        private Projectile leftFireP()
        {
            Vector2 v = new Vector2(0, 0);
            v.X = -300;
            Vector2 p = new Vector2(this.position.X, this.position.Y);
            p.X -= 20;
            return new FireBall(this.game, p, v, this.game.Content, false, this, 0, null);
        }
        private Projectile rightFireP()
        {
            Vector2 v = new Vector2(0, 0);
            v.X = 300;
            Vector2 p = new Vector2(this.position.X, this.position.Y);
            p.X += 20;
            return new FireBall(this.game, p, v, this.game.Content, false, this, 0, null);
        }

		public override void addActions()
		{
            // Create and add the various actions for this actor's idling, movement, attack, and defense.
            // NOTE: Uses VisualLoopingAction until VisualNonLoopingAction is made non-abstract.

            // RockMan Idle (nonLooping)
			IdleAction standing = new IdleAction(this, content, Vector2.Zero, ForceType.ForceInstant, 0);
            standing.addImageToLoad(@"Sprites/Bosses/Red/Move/RedStanding");

			WalkAction movingLeft = new WalkAction(this, content, new Vector2(-80, 0), ForceType.ForceInstant, 50, FACING.LEFT);
            movingLeft.addImageToLoad(@"Sprites/Bosses/Red/Move/Move/RedMoveLeft1");
            movingLeft.addImageToLoad(@"Sprites/Bosses/Red/Move/Move/RedMoveLeft2");
            movingLeft.addImageToLoad(@"Sprites/Bosses/Red/Move/Move/RedMoveLeft3");
            movingLeft.addImageToLoad(@"Sprites/Bosses/Red/Move/Move/RedMoveLeft4");
            movingLeft.addImageToLoad(@"Sprites/Bosses/Red/Move/Move/RedMoveLeft5");

			WalkAction movingRight = new WalkAction(this, content, new Vector2(80, 0), ForceType.ForceInstant, 50, FACING.RIGHT);
            movingRight.addImageToLoad(@"Sprites/Bosses/Red/Move/Move/RedMoveRight1");
            movingRight.addImageToLoad(@"Sprites/Bosses/Red/Move/Move/RedMoveRight2");
            movingRight.addImageToLoad(@"Sprites/Bosses/Red/Move/Move/RedMoveRight3");
            movingRight.addImageToLoad(@"Sprites/Bosses/Red/Move/Move/RedMoveRight4");
            movingRight.addImageToLoad(@"Sprites/Bosses/Red/Move/Move/RedMoveRight5");

            AttackAction lavaColLeft = new AttackAction(this, content, Vector2.Zero, ForceType.ForceInstant, 100, null, 10, 0, 50, 1000, 0, 60, 60, null, null, FACING.LEFT, false);
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumnLeft1");
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumnLeft2");
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumnLeft3");
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumnLeft4");
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumnLeft5");
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumnLeft6");
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumn/LavaColumn1");
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumn/LavaColumn2");
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumn/LavaColumn3");
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumn/LavaColumn4");
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumn/LavaColumn5");
            AttackAction lavaColRight = new AttackAction(this, content, Vector2.Zero, ForceType.ForceInstant, 100, null, 10, 0, 50, 1000, 0, 60, 60, null, null, FACING.RIGHT, false);
            lavaColRight.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumnRight1");
            lavaColRight.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumnRight2");
            lavaColRight.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumnRight3");
            lavaColRight.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumnRight4");
            lavaColRight.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumnRight5");
            lavaColRight.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumnRight6");
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumn/LavaColumn1");
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumn/LavaColumn2");
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumn/LavaColumn3");
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumn/LavaColumn4");
            lavaColLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/LavaColumn/LavaColumn/LavaColumn5");


            AttackAction flameThrowLeft = new AttackAction(this, content, new Vector2(0, 0), ForceType.ForceInstant, 250, createProjectiles, 0, 0, 150, 400, 0, 0, 0, null, null, FACING.LEFT, false);
                                        //new AttackAction(this, content, new Vector2(0, 0), ForceType.ForceInstant, 300, createProjectiles, 10, 0, 100, 900, 20, 100, 100, null, null, FACING.LEFT, false);
            flameThrowLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/Flamethrow/FlamethrowLeft1");
            flameThrowLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/Flamethrow/FlamethrowLeft2");
            flameThrowLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/Flamethrow/FlamethrowLeft3");
            flameThrowLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/Flamethrow/FlamethrowLeft4");

            AttackAction flameThrowRight = new AttackAction(this, content, new Vector2(0, 0), ForceType.ForceInstant, 250, createProjectiles, 0, 0, 150, 400, 0, 0, 0, null, null, FACING.RIGHT, false);
                                         //new AttackAction(this, content, new Vector2(0, 0), ForceType.ForceInstant, 300, createProjectiles, 10, 0, 100, 900, 20, 100, 100, null, null, FACING.RIGHT, false);
            flameThrowRight.addImageToLoad(@"Sprites/Bosses/Red/Attacks/Flamethrow/FlamethrowRight1");
            flameThrowRight.addImageToLoad(@"Sprites/Bosses/Red/Attacks/Flamethrow/FlamethrowRight2");
            flameThrowRight.addImageToLoad(@"Sprites/Bosses/Red/Attacks/Flamethrow/FlamethrowRight3");
            flameThrowRight.addImageToLoad(@"Sprites/Bosses/Red/Attacks/Flamethrow/FlamethrowRight4");

            AttackAction flameWhipLeft = new AttackAction(this, content, Vector2.Zero, ForceType.ForceInstant, 500, null, 0, 0, 60, 1000, 0, 40, 40, null, null, FACING.LEFT, false);
            flameWhipLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/FlameWhip/FlameWhipLeft1");
            flameWhipLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/FlameWhip/FlameWhipLeft2");
            flameWhipLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/FlameWhip/FlameWhipLeft3");
            flameWhipLeft.addImageToLoad(@"Sprites/Bosses/Red/Attacks/FlameWhip/FlameWhipLeft4");
            flameWhipLeft.offsets.ElementAt(2)[0] = -40;
            //flameWhipLeft.offsets.ElementAt(3)[0] = -2000;
            AttackAction flameWhipRight = new AttackAction(this, content, Vector2.Zero, ForceType.ForceInstant, 500, null, 0, 0, 60, 1000, 0, 40, 40, null, null, FACING.RIGHT, false);
            flameWhipRight.addImageToLoad(@"Sprites/Bosses/Red/Attacks/FlameWhip/FlameWhipRight1");
            flameWhipRight.addImageToLoad(@"Sprites/Bosses/Red/Attacks/FlameWhip/FlameWhipRight2");
            flameWhipRight.addImageToLoad(@"Sprites/Bosses/Red/Attacks/FlameWhip/FlameWhipRight3");
            flameWhipRight.addImageToLoad(@"Sprites/Bosses/Red/Attacks/FlameWhip/FlameWhipRight4");
            flameWhipRight.offsets.ElementAt(2)[0] = -40;

            DeathAction fireDeath = new DeathAction(this, content, new Vector2(0, 0), ForceType.ForceInstant, 100);
            fireDeath.addImageToLoad(@"Sprites/Bosses/Red/Death/RedDeath1");
            fireDeath.addImageToLoad(@"Sprites/Bosses/Red/Death/RedDeath2");
            fireDeath.addImageToLoad(@"Sprites/Bosses/Red/Death/RedDeath3");
            fireDeath.addImageToLoad(@"Sprites/Bosses/Red/Death/RedDeath4");
            fireDeath.addImageToLoad(@"Sprites/Bosses/Red/Death/RedDeath5");
            fireDeath.addImageToLoad(@"Sprites/Bosses/Red/Death/RedDeath6");
            fireDeath.addImageToLoad(@"Sprites/Bosses/Red/Death/RedDeath7");
            fireDeath.addImageToLoad(@"Sprites/Bosses/Red/Death/RedDeath8");
            fireDeath.addImageToLoad(@"Sprites/Bosses/Red/Death/RedDeath9");
            fireDeath.addImageToLoad(@"Sprites/Bosses/Red/Death/RedDeath10");
            // Add everything to the correct action list
			actionEngine.addIdle(standing);
            actionEngine.addMovement(movingLeft);
            actionEngine.addMovement(movingRight);
            actionEngine.addAttack(flameWhipLeft);
            actionEngine.addAttack(flameWhipRight);
            actionEngine.addAttack(lavaColLeft);
            actionEngine.addAttack(lavaColRight);
            actionEngine.addAttack(flameThrowLeft);
            actionEngine.addAttack(flameThrowRight);
            actionEngine.addDeath(fireDeath);
		}
	}
}
